<template>
  <MyBookEcharts :option="option"></MyBookEcharts>
</template>

<script>
import MyBookEcharts from "@/views/echarts/MyBookEcharts";
export default {
  name: "BookEcharts",
  components: {MyBookEcharts},
  data() {
    return {
      option: {

        color: ["#3398DB"],
        title: {
          text: '图书类型占比',
          left: "center",

          textStyle: {
            color: "rgb(14,105,136)",
            fontSize: 35,
            fontStyle: "oblique",
          },
        },
        tooltip: {},
        xAxis: {
          data: ['文学类', '历史类', '工学类', '法学类', '经济学类','统计学类','社会学类','小说类','心理学类','自然科学类','艺术类','哲学类' ]
        },
        yAxis: {},
        series: [
          {
            name: '数量',
            type: 'bar',
            data: []
          }
        ]
      }
    }
  },
  mounted() {
    this.getData()
  },
  methods:{
    getData(){
      this.$axios.get("/bookInfo/BookCount")
          .then(res=>{
            console.log(res)
            if (res.data.data){
              for(let i=0;i<res.data.data.length;i++){

                this.option.series[0].data.push(res.data.data[i].count)

              }
            }
          })

    }
  }
}
</script>

<style scoped>

</style>